{% load i18n %}

<style>
  .select2-selection.required {
    background-color: #ffffcc !important;
    /* border-color: #ff9999;
    border-width: 3px; */
  }
</style>

<div class="panel-group" id="permissions-body">
  <!-- view layer -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
          {% trans "Who can view it?" %}
        </a>
      </h4>
    </div>
    <div id="collapse1" class="panel-collapse collapse in">
      <div class="controls">
        <div class="radio">
          <label>
            <input type="checkbox" name="view_anonymous" id="perms_view_anyone" value="AnonymousUser" {% if DEFAULT_ANONYMOUS_VIEW_PERMISSION %}checked{% endif %}>
            {% trans "Anyone" %}
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="view_resourcebase_users" id="view_resourcebase_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="view_resourcebase_groups" id="view_resourcebase_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
  <!-- download layer -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
          {% trans "Who can download it?" %}
        </a>
      </h4>
    </div>
    <div id="collapse2" class="panel-collapse collapse">
      <div class="controls">
        <div class="radio">
          <label>
            <input type="checkbox" name="download_anonymous" id="perms_download_resourcebase_anyone" value="AnonymousUser" {% if DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION %}checked{% endif %}>
            {% trans "Anyone" %}
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="download_resourcebase_users" id="download_resourcebase_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="download_resourcebase_groups" id="download_resourcebase_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
  <!-- change metadata -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse3">
          {% trans "Who can change metadata for it?" %}
        </a>
      </h4>
    </div>
    <div id="collapse3" class="panel-collapse collapse">
      <div class="controls">
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="change_resourcebase_metadata_users" id="change_resourcebase_metadata_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="change_resourcebase_metadata_groups" id="change_resourcebase_metadata_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
  {% if is_layer %}
  <!-- change layer data -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse4">
          {% trans "Who can edit data for this dataset?" %}
        </a>
      </h4>
    </div>
    <div id="collapse4" class="panel-collapse collapse">
      <div class="controls">
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="change_dataset_data_users" id="change_dataset_data_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="change_dataset_data_groups" id="change_dataset_data_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
  <!-- change layer style -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse5">
          {% trans "Who can edit styles for this dataset?" %}
        </a>
      </h4>
    </div>
    <div id="collapse5" class="panel-collapse collapse">
      <div class="controls">
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="change_dataset_style_users" id="change_dataset_style_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="change_dataset_style_groups" id="change_dataset_style_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
  {% endif %}
  <!-- manage layer -->
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse6">
          {% trans "Who can manage it? (update, delete, change permissions, publish/unpublish it)" %}
        </a>
      </h4>
    </div>
    <div id="collapse6" class="panel-collapse collapse">
      <div class="controls">
        <div class="radio">
          <label>
            {% trans "The following users:" %}
            <select class="user-select" name="manage_resourcebase_users" id="manage_resourcebase_users" required></select>
          </label>
        </div>
        <div class="radio">
          <label>
            {% trans "The following groups:" %}
            <select class="group-select" name="manage_resourcebase_groups" id="manage_resourcebase_groups"></select>
          </label>
        </div>
      </div>
    </div>
  </div>
</div>
